package com.njuse.jvmfinal;

import com.njuse.jvmfinal.loading.loader;
import com.njuse.jvmfinal.memory.jclass.JClass;
import com.njuse.jvmfinal.memory.jclass.Method;
import com.njuse.jvmfinal.runtimestructure.Jframe;
import com.njuse.jvmfinal.runtimestructure.Jthread;
import com.njuse.jvmfinal.runtimestructure.interpreter;

public class Starter {
	public static String startcp;
	public static String ins="";
    public static void main(String[] args) {

    }

    /**
     * ⚠️警告：不要改动这个方法签名，这是和测试用例的唯一接口
     */
    public static void runTest(String mainClassName, String cp) {
    	
    	startcp=cp;
    	
    	loader loadingmachine=loader.getinstance();
    	
    	JClass clazz=loadingmachine.load(mainClassName, cp,1);
    	
        Jthread thread=new Jthread();
        
        clazz.init(thread);
        
        interpreter.interpret(thread);
        
        Method mainmethod=clazz.findmethod("main", "([Ljava/lang/String;)V", true);
        
        Jframe frame=new Jframe(thread,mainmethod,mainmethod.getMaxStack(),mainmethod.getMaxLocal());
        
        thread.push(frame);
        
        interpreter.interpret(thread);
       
      //  throw new RuntimeException(ins);
    }

}
